package me.cat.practice3.text5;

public class PhoneText {
    public static void main(String[] args) {
        //创建数组
        Phone[] arr = new Phone[3];

        //创建手机的对象
        Phone p1 = new Phone("小米", 1999, "白色");
        Phone p2 = new Phone("华为", 4999, "红色");
        Phone p3 = new Phone("荣耀", 3999, "蓝色");
        //把手机对象添加到数组中
        arr[0] = p1;
        arr[1] = p2;
        arr[2] = p3;
        //获取三部手机的价格
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            Phone phone = arr[i];
            sum = sum + phone.getPrice();
        }
        //求平均值
        //数据能不写死。就不写死
        double avg = sum * 1.0 / arr.length;
        System.out.println(avg);
    }
}
